package com.hzcx.app.simplechat.ui.setting.adapter;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.hzcx.app.simplechat.R;
import com.hzcx.app.simplechat.ui.setting.bean.VipInfoBean;

import java.util.List;

public class VipAdapter extends BaseQuickAdapter<VipInfoBean.PlusDataBean, BaseViewHolder> {
    public VipAdapter(@Nullable List<VipInfoBean.PlusDataBean> data) {
        super(R.layout.rv_item_vip_info, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, VipInfoBean.PlusDataBean item) {
        helper.setText(R.id.tv_content, item.getName());
        if (item.getFree_number() != 0) {
            helper.setVisible(R.id.iv_free_state, false);
            helper.setVisible(R.id.tv_free_number, true);
            helper.setText(R.id.tv_free_number, item.getFree_number() + "人");
        } else {
            helper.setVisible(R.id.iv_free_state, true);
            helper.setVisible(R.id.tv_free_number, false);
            if (item.getFree_stand() == 1) {
                helper.setImageResource(R.id.iv_free_state, R.mipmap.ic_icon_vip_item_open);
            } else {
                helper.setImageResource(R.id.iv_free_state, R.mipmap.ic_icon_vip_item_close);
            }
        }

        if (item.getPlus_number() != 0) {
            helper.setVisible(R.id.iv_plus_state, false);
            helper.setVisible(R.id.tv_plus_number, true);
            helper.setText(R.id.tv_plus_number, item.getPlus_number() + "人");
        } else {
            helper.setVisible(R.id.iv_plus_state, true);
            helper.setVisible(R.id.tv_plus_number, false);
            if (item.getPlus_stand() == 1) {
                helper.setImageResource(R.id.iv_plus_state, R.mipmap.ic_icon_vip_item_open);
            } else {
                helper.setImageResource(R.id.iv_plus_state, R.mipmap.ic_icon_vip_item_close);
            }
        }

        if (helper.getAdapterPosition() % 2 == 0) {
            helper.setBackgroundColor(R.id.cons_item, mContext.getResources().getColor(R.color.color_white));
        } else {
            helper.setBackgroundColor(R.id.cons_item, mContext.getResources().getColor(R.color.color_F6F8FB));
        }

        if (helper.getAdapterPosition() == mData.size() - 1) {
            helper.setBackgroundRes(R.id.cons_item, R.drawable.draw_white_round_bottom_15);
        }
    }
}
